package com.componentbean;

import org.springframework.stereotype.Component;

import com.bean.Computer;
import com.bean.ComputerList;
import com.bean.ComputerSelf;
import com.bean.ServiceList;

@Component
public class UserNginxSet {
	public UserNginxSet() {
		super();
		this.computerSelf = new ComputerSelf();
		this.computerList = new ComputerList();
		this.serviceList = new ServiceList();
	}
	
	public boolean copy(UserNginxSet bean) {
		if (null == bean) {
			return false;
		}
		this.computerSelf = bean.getComputerSelf();
		this.computerList = bean.getComputerList();
		this.serviceList = bean.getServiceList();
		return true;
	}
	
	ComputerSelf computerSelf;
	ComputerList computerList;
	ServiceList serviceList;
	
	public Computer getComputerById(int id) {
		if (0 == id) {
			return this.computerSelf.getMySelfDefault();
		} else if (id > 0) {
			return this.computerList.getAll().get(id);
		} else {
			return this.computerSelf.getOther().get(id);
		}
	}
	
	public String getComputerIpById(int id) {
		Computer c = this.getComputerById(id);
		return (null == c)?"":c.getIp();
	}
	
	public ComputerSelf getComputerSelf() {
		return computerSelf;
	}
	public ComputerList getComputerList() {
		return computerList;
	}
	public ServiceList getServiceList() {
		return serviceList;
	}
	
}
